package com.tfy.liquor.dao;

import com.tfy.liquor.bean.ProductImg;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * 产品主图和轮播图信息
 */
@Mapper
@Service
public interface ProductImgDao {
    // 添加产品图片信息
    @Insert("insert into product_img values(null, '${productId}', '${imgUrl}', ${type}, ${sort}, '${createTime}', 0)")
    int addProductImg(ProductImg productImg);

    // 修改产品图片状态
    @Update("update product_img set status=${status} where id=${id}")
    int editProductImgStatus(ProductImg productImg);

    // 根据产品编号获取产品图片信息
    @Select("select * from product_img where productId=${productId} and status=0 order by id asc")
    ArrayList<ProductImg> getProductImg(String ProductId);

}
